//
//  LeftDetailLabelCell.m
//  MemoryTravel
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "LeftDetailLabelCell.h"

@implementation LeftDetailLabelCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{

    self.noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(10 * WID, 20 * HEI, Width - 20 * WID, 400)];
    self.noteLabel.font = [UIFont systemFontOfSize:17];
    [self.contentView addSubview:self.noteLabel];
}

-(void)setNotes:(TravelsDetailsModel *)notes{

    _notes = notes;

    self.noteLabel.text = self.notes.imageDescription;
    self.noteLabel.numberOfLines = 0;
    [self.noteLabel sizeToFit];

    CGFloat height = [LeftDetailLabelCell heightForContent:self.notes.imageDescription];
    CGRect tempFrame = self.noteLabel.frame;
    tempFrame.size.height = height;
    self.noteLabel.frame = tempFrame;
}

+(CGFloat)heightForContent:(NSString *)content{
    CGSize size = CGSizeMake(Width - 20 * WID, 1000);
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17.0],NSFontAttributeName, nil];
    CGRect frame = [content boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return frame.size.height;
}

@end
